package com.bishe.demo.modules.common.controller;


import com.bishe.demo.modules.common.entity.ResultEntity;
import com.bishe.demo.modules.common.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api")
public class UploadController {

    @Autowired
    private UploadService uploadService;

    /**
     * 127.0.0.1/api/image/profile-big ---- post
     * 用于图片的上传
     * imageType用于标识图片的类型
     */
    @PostMapping(value = "/upload/{imageType}", consumes = "multipart/form-data")
    public ResultEntity<String> uploadImage(@RequestParam MultipartFile file, @PathVariable String imageType) {
        return uploadService.uploadImage(file, imageType);
    }
}
